/**
 * 封装本地存储
 */

// 存储
export const setItem = (key, value) => {
    if (typeof value === 'object') {
      value = JSON.stringify(value)
    }
    window.localStorage.setItem(key, value)
  }
  
  // 获取
  export const getItem = (key) => {
    try {
      const data = window.localStorage.getItem(key)
      return JSON.parse(data)
    } catch (error) {
      return localStorage.getItem(key)
    }
  }
  
  // 删除数据
  export const removeItem = (key) => {
    localStorage.removeItem(key)
  }
  